<?php defined('SYSPATH') or die('No direct script access.');

class User_Model extends Model {

    protected $session;

    public function __construct()
    {
        // load database library into $this->db (can be omitted if not required)
        parent::__construct();
        $this->session = Session::instance();
    }

    /**
     * Logowanie użytkownika .
     * @param login nazwa użytkownika
     * @param haslo hasło użytkownika
     * @return void
     */
    public function logowanie($login,$haslo)
    {
        $sql = 'SELECT * FROM `user` WHERE (`login`=?) AND (`pass`=?)';
        $result = $this->db->query($sql,array($login,$haslo));

        if($result->count()==1){
            $user = $result->current();
            $this->session->set('user',$user);
            return true ;
        } else {
            return false;
        }
    }
}